// 数组的深拷贝
let deepcloneArray = arr1 => {
    let arr2 = []
    arr1.forEach((value,index) => {
        if(typeof(value) === 'object') {
            arr2[index] = deepcloneArray(value)
        }
        else {
            arr2[index] = value
        }
    })
    return arr2
}
let arr1 = [1, [2, 3, 4], 5]
let arr2 = deepcloneArray(arr1)
arr1[1][2] = 9
console.log(arr2[1][2]) //4

// 如果这里面的数据既有对象,又有数组,这时候的深拷贝
// example:[1, 2, 3, {a:1, b:2, c:[4, 5, 6]}] 或者是{1:1, b:2, c:[1, 2, {a:4, b:5},]}

// 判断值的类型是数组还是对象
let type1 = Object.prototype.toString.call({}).slice(8, -1)
console.log(type1)

let type2 = Object.prototype.toString.call([]).slice(8, -1)
console.log(type2)

















